<?php
/*
 * Template Name:导航模板
 *
 * A custom page template without sidebar.
 *
 * @package BuddyPress
 * @subpackage BP_Default
 * @since 1.6
 */
?>
<?php get_header();?>
<section>
<div class="container">
<div class="sjdqWrapBox">
<div class="sjdqList">
	<div class="showType">
		<?php wp_bac_breadcrumb();?>
	</div>
	<div class="sjdqBgBox sjdh">
		<?php
		global $uctheme_option;
		$count=(int)$uctheme_option['malltype']['malltype_count'];
		$mall_type = array();
		for($i=0;$i<$count;$i++){
			if( $uctheme_option['malltype']['malltype_name_'.$i] != '' ){
				$key = $uctheme_option['malltype']['malltype_name_'.$i];
				$value = $uctheme_option['malltype']['malltype_title_'.$i];
				$mall_type[$key]=$value;
			}
		}
		?>
        
		<script type="text/javascript" >
        function scrollToPosition(id) {
            var t = $('.'+id).position().top;
            $(window).scrollTop(t-25);
            return false;
        }
        </script>

		<div class="fontTitle zhsc">商家导航</div>
        
            <div class="aclist">
                <?php if( is_array($mall_type) ){
                foreach($mall_type as $key=>$type){
                ?>
                <a href="javascript:viod(0);" onclick="return scrollToPosition('<?php echo $key;?>');">
                <?php echo $type;?>
                </a>
                <?php } } ?>
            </div>
            
        
		<div class="clear" id="zhsc"></div>
	</div>
	<?php if( is_array($mall_type) ) : foreach($mall_type as $key=>$type){ ?>
	<div class="sjdqBgBox">
		<dl class="sjdqBox">
			<dt class="fontTitle <?php echo $key;?>"><?php echo $type;?></dt>
			<?php $terms = get_term_meta_by_key_value( '_mall_type' );
			if( is_array($terms) ){
			foreach( $terms as $termid ){
			if( get_term_meta($termid,'_mall_type',true) != $key ) continue;
			$term = get_term( $termid, 'mall' );
			$termid=(int)$termid;
			?>
			<dd>
				<div class="sjdqOutBorder">
					<div class="sjdqInnerBorder">
						<a class="sjdqLogo" href="<?php echo get_term_link($termid,'mall');?>" rel="nofollow"><img src="<?php echo get_term_meta($termid , '_mall_icon',true);?>" alt="<?php echo $term->name;?>"/></a>
						<a class="sjdqName" href="<?php echo get_term_link($termid,'mall');?>" rel="nofollow"><?php echo $term->name;?></a>
					</div>
					<div class="sjdqTipBox">
						<div class="sjdqTip">
							<span class="blue"><a href="<?php echo  get_term_link($termid,'mall');?>"><?php echo $term->name;?></a></span>
							<div class="tipInfo">
							<?php echo mb_substr(get_term_meta($termid , '_mall_desc',true),0,50,'UTF-8');
							?>
							</div>
							<div class="tipLine">
								<strong>推荐指数：</strong><span class="red">
								<?php $level = (int)get_term_meta($termid, '_mall_args',true);for($i=1;$i<=$level;$i++){	echo '★';}?>
								</span><br/>
							</div>
						</div>
						<div class="tipArrowBot"></div>
					</div>
				</div>
				<div class="sjdqBot">
					<div class="sjdqBotLeft"><a href="<?php echo  get_term_link($termid,'mall');?>">商家详情</a></div>
					<div class="sjdqBotRight"><a href="<?php echo addhttp(get_term_meta($termid, '_mall_link',true));?>" rel="nofollow" target="_blank">直达商城</a></div>
					<div class="clear"></div>
				</div>				
			</dd>
			<?php }
			}
			?>
		</dl>
		<div class="clear" id="smjd"></div>
	</div>
	<?php } endif;?>
</div>
</div>
<div class="clear"></div>
</div>
</section>
<?php get_footer();?>